<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : editMatch.xsl
    Created on : 28.4.2010, 18:22:46
    Author     : Football-Statistics Team
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" omit-xml-declaration="yes" media-type="html/text"/>
    <xsl:param name="url"/>
    <xsl:param name="league"/>
    <xsl:param name="season"/>
    <xsl:param name="date"/>
    <xsl:param name="time"/>
    <xsl:param name="round"/>
    <xsl:param name="goals"/>
    <xsl:param name="cards"/>
    <xsl:param name="changes"/>
    <xsl:param name="players"/>
    <xsl:param name="stadium"/>
    <xsl:param name="referee"/>
    <xsl:param name="spectators"/>
    <xsl:param name="home"/>
    <xsl:param name="guests"/>
    <xsl:param name="score"/>
    <xsl:template match="/match">
        <table border="0" class="match">
            <tr>
                <td class="label"><xsl:value-of select="$league"/></td>
                <td><input type="text" name="league" value="{league}"/></td>
            </tr>
            <tr class="odd">
                <td class="label"><xsl:value-of select="$season"/></td>
                <td><input type="text" name="season" value="{season}"/></td>
            </tr>
            <tr>
                <td class="label"><xsl:value-of select="$round"/></td>
                <td><input type="text" name="round" value="{round}"/></td>
            </tr>
            <tr class="odd">
                <td class="label"><xsl:value-of select="$date"/></td>
                <td><input type="text" name="date" value="{date}"/></td>
            </tr>
            <tr>
                <td class="label"><xsl:value-of select="$time"/></td>
                <td><input type="text" name="time" value="{time}"/></td>
            </tr>
            <tr class="odd">
                <td class="label"><xsl:value-of select="$home"/></td>
                <td><input type="text" name="home" value="{home}"/></td>
            </tr>
            <tr>
                <td class="label"><xsl:value-of select="$guests"/></td>
                <td><input type="text" name="guests" value="{guests}"/></td>
            </tr>
            <tr class="odd">
                <td class="label"><xsl:value-of select="$score"/></td>
                <td><input type="text" name="score_full_home" value="{score/full/@home}" size="1"/>:<input type="text" name="score_full_guests" value="{score/full/@guests}" size="1"/>(<input type="text" name="score_half_home" value="{score/half/@home}" size="1"/>:<input type="text" name="score_half_guests" value="{score/half/@guests}" size="1"/>)</td>
            </tr>
            <tr>
                <td class="label"><xsl:value-of select="$goals"/><xsl:text> </xsl:text><xsl:value-of select="$home"/></td>
                <td id="goals_home">
                    <xsl:if test="count(goals/goal[@team=1])>0"><xsl:text>Minute | Player</xsl:text><br/></xsl:if>
                    <xsl:for-each select="goals/goal[@team=1]">
                        <xsl:variable name="counter" select="position()-1" />
                        <input type="text" onChange="javascript:saveHomeGoalMinute({$counter},this.value)" value="{@minute}" name="goals_home_minute_{$counter}" size="1"/> | <input type="text" onChange="javascript:saveHomeGoalPlayer({$counter},this.value)" value="{@player}" name="goals_home_player_{$counter}"/><br/>
                    </xsl:for-each>
                    <xsl:variable name="counter" select="count(goals/goal[@team=1])" />
                    <input type="hidden" name="goals_home_num" value="{$counter}"/>
                </td>
            </tr>
            <tr>    
                <td class="label"></td>
                <td><a href="javascript:addHomeGoal('goals_home')">Add goal</a> | <a href="javascript:deleteHomeGoal('goals_home')">Remove goal</a></td>
            </tr>
            <tr class="odd">
                <td class="label"><xsl:value-of select="$goals"/><xsl:text> </xsl:text><xsl:value-of select="$guests"/></td>
                <td id="goals_guests">
                    <xsl:if test="count(goals/goal[@team=2])>0"><xsl:text>Minute | Player</xsl:text><br/></xsl:if>
                    <xsl:for-each select="goals/goal[@team=2]">
                        <xsl:variable name="counter" select="position()-1" />
                        <input type="text" onChange="javascript:saveGuestsGoalMinute({$counter},this.value)" value="{@minute}" name="goals_guests_minute_{$counter}" size="1"/> | <input type="text" onChange="javascript:saveGuestsGoalPlayer({$counter},this.value)" value="{@player}" name="goals_guests_player_{$counter}"/><br/>
                    </xsl:for-each>
                    <xsl:variable name="counter" select="count(goals/goal[@team=2])" />
                    <input type="hidden" name="goals_guests_num" value="{$counter}"/>
                </td>
            </tr>
            <tr class="odd">    
                <td class="label"></td>
                <td><a href="javascript:addGuestsGoal('goals_guests')">Add goal</a> | <a href="javascript:deleteGuestsGoal('goals_guests')">Remove goal</a></td>
            </tr>
            <tr>
                <td class="label"><xsl:value-of select="$cards"/><xsl:text> </xsl:text><xsl:value-of select="$home"/></td>
                <td id="cards_home">
                    <xsl:if test="count(cards/card[@team=1])>0"><xsl:text>Minute | Type | Player</xsl:text><br/></xsl:if>
                    <xsl:for-each select="cards/card[@team=1]">
                        <xsl:variable name="counter" select="position()-1" />
                        <input type="text" onChange="javascript:saveHomeCardMinute({$counter},this.value)" value="{@minute}" name="cards_home_minute_{$counter}" size="1"/> | <input type="text" onChange="javascript:saveHomeCardType({$counter},this.value)" value="{@type}" name="cards_home_type_{$counter}" size="3"/> | <input type="text" onChange="javascript:saveHomeCardPlayer({$counter},this.value)" value="{@player}" name="cards_home_player_{$counter}"/><br/>
                    </xsl:for-each>
                    <xsl:variable name="counter" select="count(cards/card[@team=1])" />
                    <input type="hidden" name="cards_home_num" value="{$counter}"/>
                </td>
            </tr>
            <tr>    
                <td class="label"></td>
                <td><a href="javascript:addHomeCard('cards_home')">Add card</a> | <a href="javascript:deleteHomeCard('cards_home')">Remove card</a></td>
            </tr>
            <tr class="odd">
                <td class="label"><xsl:value-of select="$cards"/><xsl:text> </xsl:text><xsl:value-of select="$guests"/></td>
                <td id="cards_guests">
                    <xsl:if test="count(cards/card[@team=2])>0"><xsl:text>Minute | Type | Player</xsl:text><br/></xsl:if>
                    <xsl:for-each select="cards/card[@team=2]">
                        <xsl:variable name="counter" select="position()-1" />
                        <input type="text" onChange="javascript:saveGuestsCardMinute({$counter},this.value)" value="{@minute}" name="cards_guests_minute_{$counter}" size="1"/> | <input type="text" onChange="javascript:saveGuestsCardType({$counter},this.value)" value="{@type}" name="cards_guests_type_{$counter}" size="3"/> | <input type="text" onChange="javascript:saveGuestsCardPlayer({$counter},this.value)" value="{@player}" name="cards_guests_player_{$counter}"/><br/>
                    </xsl:for-each>
                    <xsl:variable name="counter" select="count(cards/card[@team=2])" />
                    <input type="hidden" name="cards_guests_num" value="{$counter}"/>
                </td>
            </tr>
            <tr class="odd">    
                <td class="label"></td>
                <td><a href="javascript:addGuestsCard('cards_guests')">Add card</a> | <a href="javascript:deleteGuestsCard('cards_guests')">Remove card</a></td>
            </tr>
            <tr>
                <td class="label"><xsl:value-of select="$changes"/><xsl:text> </xsl:text><xsl:value-of select="$home"/></td>
                <td id="changes_home">
                    <xsl:if test="count(changes/change[@team=1])>0"><xsl:text>Minute | In | Out</xsl:text><br/></xsl:if>
                    <xsl:for-each select="changes/change[@team=1]">
                        <xsl:variable name="counter" select="position()-1" />
                        <input type="text" onChange="javascript:saveHomeChangeMinute({$counter},this.value)" value="{@minute}" name="changes_home_minute_{$counter}" size="1"/> | <input type="text" onChange="javascript:saveHomeChangeIn({$counter},this.value)" value="{@in}" name="changes_home_in_{$counter}"/> | <input type="text" onChange="javascript:saveHomeChangeOut({$counter},this.value)" value="{@out}" name="changes_home_out_{$counter}"/><br/>
                    </xsl:for-each>
                    <xsl:variable name="counter" select="count(changes/change[@team=1])" />
                    <input type="hidden" name="changes_home_num" value="{$counter}"/>
                </td>
            </tr>
            <tr>    
                <td class="label"></td>
                <td><a href="javascript:addHomeChange('changes_home')">Add change</a> | <a href="javascript:deleteHomeChange('changes_home')">Remove change</a></td>
            </tr>
            <tr class="odd">
                <td class="label"><xsl:value-of select="$changes"/><xsl:text> </xsl:text><xsl:value-of select="$guests"/></td>
                <td id="changes_guests">
                    <xsl:if test="count(changes/change[@team=2])>0"><xsl:text>Minute | In | Out</xsl:text><br/></xsl:if>
                    <xsl:for-each select="changes/change[@team=2]">
                        <xsl:variable name="counter" select="position()-1" />
                        <input type="text" onChange="javascript:saveGuestsChangeMinute({$counter},this.value)" value="{@minute}" name="changes_guests_minute_{$counter}" size="1"/> | <input type="text" onChange="javascript:saveGuestsChangeIn({$counter},this.value)" value="{@in}" name="changes_guests_in_{$counter}"/> | <input type="text" onChange="javascript:saveGuestsChangeOut({$counter},this.value)" value="{@out}" name="changes_guests_out_{$counter}"/><br/>
                    </xsl:for-each>
                    <xsl:variable name="counter" select="count(changes/change[@team=2])" />
                    <input type="hidden" name="changes_guests_num" value="{$counter}"/>
                </td>
            </tr>
            <tr class="odd">    
                <td class="label"></td>
                <td><a href="javascript:addGuestsChange('changes_guests')">Add change</a> | <a href="javascript:deleteGuestsChange('changes_guests')">Remove change</a></td>
            </tr>
            <tr>
                <td class="label"><xsl:value-of select="$players"/><xsl:text> </xsl:text><xsl:value-of select="$home"/></td>
                <td id="players_home">
                    <xsl:if test="count(home-team/player)>0"><xsl:text>Player name</xsl:text><br/></xsl:if>
                    <xsl:for-each select="home-team/player">
                        <xsl:variable name="counter" select="position()-1" />
                        <input type="text" onChange="javascript:saveHomePlayer({$counter},this.value)" value="{@name}" name="players_home_player_{$counter}"/><br/>
                    </xsl:for-each>
                    <xsl:variable name="counter" select="count(home-team/player)" />
                    <input type="hidden" name="players_home_num" value="{$counter}"/>
                </td>
            </tr>
            <tr>    
                <td class="label"></td>
                <td><a href="javascript:addHomePlayer('players_home')">Add player</a> | <a href="javascript:deleteHomePlayer('players_home')">Remove player</a></td>
            </tr>
            <tr class="odd">
                <td class="label"><xsl:value-of select="$players"/><xsl:text> </xsl:text><xsl:value-of select="$guests"/></td>
                <td id="players_guests">
                    <xsl:if test="count(guest-team/player)>0"><xsl:text>Player name</xsl:text><br/></xsl:if>
                    <xsl:for-each select="guest-team/player">
                        <xsl:variable name="counter" select="position()-1" />
                        <input type="text" onChange="javascript:saveGuestsPlayer({$counter},this.value)" value="{@name}" name="players_guests_player_{$counter}"/><br/>
                    </xsl:for-each>
                    <xsl:variable name="counter" select="count(guest-team/player)" />
                    <input type="hidden" name="players_guests_num" value="{$counter}"/>
                </td>
            </tr>
            <tr class="odd">    
                <td class="label"></td>
                <td><a href="javascript:addGuestsPlayer('players_guests')">Add player</a> | <a href="javascript:deleteGuestsPlayer('players_guests')">Remove player</a></td>
            </tr>
            <tr>
                <td class="label"><xsl:value-of select="$referee"/></td>
                <td><input type="text" name="referee" value="{referee}"/></td>
            </tr>
            <tr class="odd">
                <td class="label"><xsl:value-of select="$stadium"/></td>
                <td><input type="text" name="stadium" value="{stadium}"/></td>
            </tr>
            <tr>
                <td class="label"><xsl:value-of select="$spectators"/></td>
                <td><input type="text" name="spectators" value="{spectators}"/></td>
            </tr>
        </table>
    </xsl:template>
</xsl:stylesheet>
